feat(core): Add enableTruncation option to Vercel AI integration#20195
feat(core): Add enableTruncation option to Vercel AI integration#20195nicohrubec wants to merge 3 commits intodevelopfrom
enableTruncation option to Vercel AI integration#20195Conversation
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Core
Deps
Bug Fixes 🐛
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
size-limit report 📦
|
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
| const enableTruncation = integration?.options?.enableTruncation ?? true; | ||
|
|
||
| processGenerateSpan(span, name, attributes, enableTruncation); |
There was a problem hiding this comment.
Bug: The enableTruncation option for vercelAIIntegration is only implemented for Node.js. On other platforms (Cloudflare, Deno, Vercel Edge), truncation is always enabled and cannot be configured.
Severity: MEDIUM
Suggested Fix
To ensure consistent behavior, extend the vercelAIIntegration in the Cloudflare, Deno, and Vercel Edge packages to accept and store an options object, similar to the Node.js implementation. Alternatively, document that the enableTruncation option is only available for the Node.js SDK.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: packages/core/src/tracing/vercel-ai/index.ts#L122-L124
Potential issue: The core tracing logic attempts to read
`integration?.options?.enableTruncation` to control message truncation for the Vercel AI
integration. However, the integration factory function was only updated to accept and
store these options for the Node.js SDK. For other platforms like Cloudflare, Deno, and
Vercel Edge, the integration object has no `options` property. The code defensively
falls back to `true`, meaning truncation is permanently enabled on these non-Node
platforms with no way for users to disable it, creating a feature disparity.
Did we get this right? 👍 / 👎 to inform future reviews.
There was a problem hiding this comment.
@nicohrubec this is legit, e.g.:
Doesn't take any options.
This PR adds an enableTruncation option to the Vercel GenAI integration that allows users to disable input message truncation. It defaults to true to preserve existing behavior.
Closes #20140